package com.joysuch.wwyt.risk.repository;

import com.joysuch.wwyt.risk.entity.RiskEvaluationAnalyzeWay;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface RiskEvaluationAnalyzeWayDao extends JpaRepository<RiskEvaluationAnalyzeWay, Long> {

    int countByNameAndAnalyzeType(String name, Integer analyzeType);

    int countByCodeAndAnalyzeType(String code, Integer analyzeType);

    @Query(value = "SELECT * FROM wwyt_risk_evaluation_analyze_way WHERE analyze_type = ?1 AND delete_flag = '0'", nativeQuery = true)
    List<RiskEvaluationAnalyzeWay> getListByAnalyzeType(Integer analyzeType);

    int countByEvaluationId(Long analyzeId);

    @Query(value = "SELECT * FROM wwyt_risk_evaluation_analyze_way WHERE analyze_type = ?1 AND evaluation_id IS NOT NULL AND delete_flag = '0'", nativeQuery = true)
    List<RiskEvaluationAnalyzeWay> getPointAnalyzeWayList(Integer analyzeType);

    List<RiskEvaluationAnalyzeWay> findByEvaluationId(Long wayId);

    RiskEvaluationAnalyzeWay findByNameAndAnalyzeType(String analyzeName, int i);
}
